﻿@using CarCareTracker.Helper
@inject IConfigHelper config
@inject ITranslationHelper translator
@{
    var userConfig = config.GetUserConfig(User);
    var userLanguage = userConfig.UserLanguage;
}
@{
    ViewData["Title"] = "Garage";
}
@section Scripts {
    <script src="~/js/garage.js?v=@StaticHelper.VersionNumber"></script>
    <script src="~/js/settings.js?v=@StaticHelper.VersionNumber"></script>
    <script src="~/js/supplyrecord.js?v=@StaticHelper.VersionNumber"></script>
    <script src="~/lib/drawdown/drawdown.js"></script>
}
@section Nav {
    <div class="container-fluid lubelogger-navbar-container frosted hideOnPrint">
        <div class="row mt-2">
            <div class="d-flex lubelogger-navbar">
                <div class="me-2" style="cursor:pointer;" onclick="returnToGarage()">
                    <img src="@config.GetSmallLogoUrl()" class="lubelogger-logo lubelogger-tab" />
                    <img src="@config.GetLogoUrl()" class="lubelogger-logo lubelogger-mobile-nav-show" />
                </div>
                <ul class="nav nav-tabs lubelogger-tab flex-grow-1" id="homeTab" role="tablist">
                    <li class="nav-item" role="presentation">
                        <button class="nav-link resizable-nav-link" id="garage-tab" data-bs-toggle="tab" data-bs-target="#garage-tab-pane" type="button" role="tab"><i class="bi bi-car-front"></i><span class="ms-2">@translator.Translate(userLanguage, "Garage")</span></button>
                    </li>
                    @if (config.GetServerEnableShopSupplies())
                    {
                        <li class="nav-item" role="presentation">
                            <button class="nav-link resizable-nav-link" id="supply-tab" data-bs-toggle="tab" data-bs-target="#supply-tab-pane" type="button" role="tab" aria-selected="false"><i class="bi bi-shop"></i><span class="ms-2">@translator.Translate(userLanguage, "Supplies")</span></button>
                        </li>
                    }
                    @if (userConfig.ShowCalendar)
                    {
                        <li class="nav-item" role="presentation">
                            <button class="nav-link resizable-nav-link" id="calendar-tab" data-bs-toggle="tab" data-bs-target="#calendar-tab-pane" type="button" role="tab" aria-selected="false"><i class="bi bi-calendar-week"></i><span class="ms-2">@translator.Translate(userLanguage, "Calendar")</span></button>
                        </li>
                    }
                    <li class="nav-item dropdown nav-item-persist nav-item-more me-5" role="presentation" style="display:none;">
                        <a class="nav-link resizable-nav-link" data-bs-toggle="dropdown" href="#" role="button" aria-expanded="false"><i class="bi bi-three-dots"></i></a>
                        <ul class="dropdown-menu">
                        </ul>
                    </li>
                    <li class="nav-item ms-auto" role="presentation">
                        <button class="nav-link resizable-nav-link" id="settings-tab" data-bs-toggle="tab" data-bs-target="#settings-tab-pane" type="button" role="tab"><i class="bi bi-gear"></i><span class="ms-2">@translator.Translate(userLanguage, "Settings")</span></button>
                    </li>
                    @if (User.IsInRole("CookieAuth") || User.IsInRole("APIAuth"))
                    {
                        <li class="nav-item dropdown nav-item-persist" role="presentation">
                            <a class="nav-link resizable-nav-link dropdown-toggle" data-bs-toggle="dropdown" href="#" role="button" aria-expanded="false"><i class="bi bi-person"></i><span class="ms-2">@User.Identity.Name</span></a>
                            <ul class="dropdown-menu">
                                @if (User.IsInRole(nameof(UserData.IsAdmin)))
                                {
                                    <li>
                                        <a class="dropdown-item" href="/Admin"><i class="bi bi-people me-2"></i>@translator.Translate(userLanguage, "Admin Panel")</a>
                                    </li>
                                }
                                @if (User.IsInRole(nameof(UserData.IsRootUser)))
                                {
                                    <li>
                                        <button class="dropdown-item" onclick="showRootAccountInformationModal()"><i class="bi bi-person-gear me-2"></i>@translator.Translate(userLanguage, "Profile")</button>
                                    </li>
                                }
                                else
                                {
                                    <li>
                                        <button class="dropdown-item" onclick="showAccountInformationModal()"><i class="bi bi-person-gear me-2"></i>@translator.Translate(userLanguage, "Profile")</button>
                                    </li>
                                    <li>
                                        <button class="dropdown-item" onclick="showHouseholdModal()"><i class="bi bi-house me-2"></i>@translator.Translate(userLanguage, "Household")</button>
                                    </li>
                                }
                                <li><hr class="dropdown-divider"></li>
                                <li>
                                    <button class="dropdown-item" onclick="performLogOut()"><i class="bi bi-box-arrow-right me-2"></i>@translator.Translate(userLanguage, "Logout")</button>
                                </li>
                            </ul>
                        </li>
                    }
                </ul>
                <div class="lubelogger-navbar-button">
                    <button type="button" class="btn btn-adaptive" onclick="showMobileNav()"><i class="bi bi-list lubelogger-menu-icon"></i></button>
                </div>
            </div>
        </div>
        <hr />
    </div>
}
<div class="lubelogger-mobile-nav" onclick="hideMobileNav()">
    <ul class="navbar-nav" id="homeTab" role="tablist">
        <li class="nav-item" role="presentation">
            <button class="nav-link" id="garage-tab" data-bs-toggle="tab" data-bs-target="#garage-tab-pane" type="button" role="tab"><span class="ms-2 display-3"><i class="bi bi-car-front me-2"></i>@translator.Translate(userLanguage,"Garage")</span></button>
        </li>
        @if(config.GetServerEnableShopSupplies())
        {
            <li class="nav-item" role="presentation">
                <button class="nav-link" id="supply-tab" data-bs-toggle="tab" data-bs-target="#supply-tab-pane" type="button" role="tab"><span class="ms-2 display-3"><i class="bi bi-shop me-2"></i>@translator.Translate(userLanguage, "Supplies")</span></button>
            </li>
        }
        @if(userConfig.ShowCalendar){
            <li class="nav-item" role="presentation">
                <button class="nav-link" id="calendar-tab" data-bs-toggle="tab" data-bs-target="#calendar-tab-pane" type="button" role="tab"><span class="ms-2 display-3"><i class="bi bi-calendar-week me-2"></i>@translator.Translate(userLanguage, "Calendar")</span></button>
            </li>
        }
        <li class="nav-item" role="presentation">
            <button class="nav-link" id="settings-tab" data-bs-toggle="tab" data-bs-target="#settings-tab-pane" type="button" role="tab"><span class="ms-2 display-3"><i class="bi bi-gear me-2"></i>@translator.Translate(userLanguage,"Settings")</span></button>
        </li>
        @if (User.IsInRole("CookieAuth") || User.IsInRole("APIAuth"))
        {
            @if (User.IsInRole(nameof(UserData.IsAdmin)))
            {
                <li class="nav-item" role="presentation">
                    <a class="dropdown-item" href="/Admin"><span class="display-3 ms-2"><i class="bi bi-people me-2"></i>@translator.Translate(userLanguage,"Admin Panel")</span></a>
                </li>
            }
            @if (User.IsInRole(nameof(UserData.IsRootUser)))
            {
                <li>
                    <button class="nav-link" onclick="showRootAccountInformationModal()"><span class="display-3 ms-2"><i class="bi bi-person-gear me-2"></i>@translator.Translate(userLanguage, "Profile")</span></button>
                </li>
            } else
            {
                <li>
                    <button class="nav-link" onclick="showAccountInformationModal()"><span class="display-3 ms-2"><i class="bi bi-person-gear me-2"></i>@translator.Translate(userLanguage, "Profile")</span></button>
                </li>
                <li>
                    <button class="nav-link" onclick="showHouseholdModal()"><span class="display-3 ms-2"><i class="bi bi-house me-2"></i>@translator.Translate(userLanguage, "Household")</span></button>
                </li>
            }
            <li class="nav-item" role="presentation">
                <button class="nav-link" onclick="performLogOut()"><span class="display-3 ms-2"><i class="bi bi-box-arrow-right me-2"></i>@translator.Translate(userLanguage,"Logout")</span></button>
            </li>
        }
    </ul>
</div>
<div class="container">
    <div class="tab-content" id="homeTab">
        <div class="tab-pane fade" id="garage-tab-pane" role="tabpanel" tabindex="0">
        </div>
        <div class="tab-pane fade" id="supply-tab-pane" role="tabpanel" tabindex="0">
        </div>
        <div class="tab-pane fade" id="calendar-tab-pane" role="tabpanel" tabindex="0">
        </div>
        <div class="tab-pane fade" id="settings-tab-pane" role="tabpanel" tabindex="0">
        </div>
    </div>
</div>

<div class="modal fade" id="addVehicleModal" tabindex="-1" role="dialog">
    <div class="modal-dialog modal-lg" role="document">
        <div class="modal-content" id="addVehicleModalContent">
        </div>
    </div>
</div>
<div class="modal fade" id="bulkImportModal" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content" id="bulkImportModalContent">
        </div>
    </div>
</div>
<div class="modal fade" id="accountInformationModal" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content" id="accountInformationModalContent">
        </div>
    </div>
</div>
<div class="modal fade" data-bs-focus="false" id="householdModal" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content" id="householdModalContent">
        </div>
    </div>
</div>
<div class="modal fade" data-bs-focus="false" id="attachmentPreviewModal" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog modal-fullscreen" role="document">
        <div class="modal-content frosted" id="attachmentPreviewModalContent">
        </div>
    </div>
</div>
<div class="modal fade" data-bs-focus="false" id="userCollaboratorsModal" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog" role="document">
        <div class="modal-content" id="userCollaboratorsModalContent">
        </div>
    </div>
</div>
<div class="stickerPrintContainer hideOnPrint">
</div>
<script>
    bindWindowResize();
    checkNavBarOverflow();
</script>